import React from 'react';
import Route from 'react-router/lib/Route';
import { IndexRedirect } from 'react-router';
import { WeaErrorPage, WeaLocaleProvider,WeaTools } from 'ecCom'
import Home from './components/Home';

import './style/icon.css';
import './style/index.css';
import stores from './stores';
import Detail from "./components/Detail";
import outDetail from "./components/OutDetail";
import FileView from "./components/FileView";
import DetailForm from "./components/DetailForm";
const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'document');
const getLabel = WeaLocaleProvider.getLabel;



class Error extends React.Component {
  render() {
    return (
      <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@m22rx1`} msg={getLabel('384713', "对不起，无法找到该页面！")} />
    )
  }
}

const onEnter = (nextState, replace, callback) => {
    WeaTools.checkSSO('', false).then(() => {
        getLocaleLabel(nextState, replace, callback)
    })
}

const Routes = (
  <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@7ksfv2`} path='document' component={Home}>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@ydk6el`} name='detail' path='detail'  onEnter={onEnter} component={ Detail } />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@xvg81m`} name='outDetail' path='outDetail' component={ outDetail } />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@u930z1`} name='fileView' path='fileView' onEnter={onEnter} component={ FileView } />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@6to5hr`} name='edit' path='edit' onEnter={onEnter} component={ DetailForm } />
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@bmaj0u`} path="*" component={Error}></Route>
  </Route>
);

module.exports = {
  Route: Routes,
  store: stores,
};

